import './scss/index.scss'
import './utils/mobile'
import { dateFormat, fixed, formatHash } from './utils/utils'
import { TLoading } from './directive/TLoading/TGlobalLoading'
import { TMessage } from './directive/TMessage/globalMessage'
import { TConfirm } from './directive/TConfirm/TGlobalConfirm'
import { i18n } from './language'
import TCopy from './directive/TCopy/TCopy'
import Tooltip from './directive/TTooltip/TTooltip'
import Loading from './directive/TLoading/TLoading'
import TButton from './TButton/TButton.vue'
import TPicker from './TPicker/TPicker.vue'
import TInput from './TInput/TInput.vue'
import TModal from './TModal/TModal.vue'
import TPopup from './TPopup/TPopup.vue'
import TImage from './TImage/TImage.vue'
import TStep from './TStep/TStep.vue'
import TMore from './TMore/TMore.vue'
import TTabs from './TTabs/TTabs.vue'
import TTabsItem from './TTabs/TTabsItem.vue'
import TTabsTitle from './TTabs/TTabsTitle.vue'
import TCountdown from './TCountdown/TCountdown.vue'
import TGlobalSetting from './TGlobalSetting/TGlobalSetting.vue'
import type { App } from 'vue'

export {
  TButton,
  TPicker,
  TInput,
  TModal,
  TPopup,
  TImage,
  TStep,
  TMore,
  TTabs,
  TTabsItem,
  TTabsTitle,
  TCountdown,
  TGlobalSetting,
  TLoading,
  TMessage,
  TConfirm
}

const globalFun = {
  install: (app: App): void => {
    app.use(i18n)

    app.config.globalProperties.$dateFormat = dateFormat
    app.config.globalProperties.$formatHash = formatHash
    app.config.globalProperties.$fixed = fixed

    app.component('TButton', TButton)
    app.component('TPicker', TPicker)
    app.component('TInput', TInput)
    app.component('TModal', TModal)
    app.component('TPopup', TPopup)
    app.component('TImage', TImage)
    app.component('TStep', TStep)
    app.component('TMore', TMore)
    app.component('TTabs', TTabs)
    app.component('TTabsItem', TTabsItem)
    app.component('TTabsTitle', TTabsTitle)
    app.component('TCountdown', TCountdown)
    app.component('TGlobalSetting', TGlobalSetting)

    app.directive('tooltip', Tooltip)
    app.directive('load', Loading)
    app.directive('copy', TCopy)
  }
}

export default globalFun
